package com.ttnet.listeners;

import java.util.Date;

import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;

import com.ttnet.model.BaseModel;

public class EntityListener {

	@PrePersist
	public void onPrePersist(Object object) {
		if (object instanceof BaseModel) {
			BaseModel record = (BaseModel) object;
			record.setLastUpdateTime(new Date());
			record.setCreateTime(new Date());
		}
	}

	@PreUpdate
	public void onPreUpdate(Object object) {
		if (object instanceof BaseModel) {
			BaseModel record = (BaseModel) object;
			record.setLastUpdateTime(new Date());
		}
	}
}
